﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using AvalonDock;
using PefStudio.Base;
using PefStudio.Windows;

namespace PefStudio.Windows
{
    [Export(MainWindow.MainToolBarsContract, typeof(IToolBar))]
    sealed class ToolStrip1_Test : AbstractToolBar
    {
        public ToolStrip1_Test()
        {
            this.ID = "Test1";
        }

        [ImportMany("ToolTest", typeof(IToolBarItem), AllowRecomposition = true)]
        private IEnumerable<IToolBarItem> _toolStripItems { get; set; }

        public override void OnImportsSatisfied()
        {
            CreateService.CreateToolbar(Items, _toolStripItems);
        }
    }

    [Export(MainWindow.MainMenuContract, typeof(IMenuItem))]
    sealed class FM_Test : AbstractMenuItem
    {
        public FM_Test()
        {
            this.ID = "Test";
            this.Header = "Test";

            InsertRelativeToID = "File";
            HasSeparator = true;
        }

        protected override void OnClick()
        {
            var frm = MainWindow.CompositionContainer.GetExportedValue<IDocument>("Form");// < AbstractDocument > ("Form");
            MainWindow.DockManager.ShowDocument((AbstractDocument)frm);
        }
    }

    [Export(MainWindow.MainMenuContract, typeof(IMenuItem))]
    sealed class FM1_Test : AbstractMenuItem
    {
        public FM1_Test()
        {
            this.ID = "Test1";
            this.Header = "FullScreen";

            InsertRelativeToID = "File";
        }

        protected override void OnClick()
        {
            MainWindow.FullScreen = !MainWindow.FullScreen;
        }
    }

    [Export(MainWindow.LoadedCommandsContract, typeof(ICommand))]
    class FirstCommand : AbstractCommand
    {
        public override void Run(params object[] args)
        {
            MainWindow.SetMessage("Ready");
            MainWindow.SetProgress(90);
        }
    }

    [Export(MainWindow.ClosingCommandsContract, typeof(ICancelabelCommand))]
    class LastCommand : AbstractCommand, ICancelabelCommand
    {
        public override void Run(params object[] args)
        {
            Cancel = MessageBox.Show("Exit ?", "Info", MessageBoxButton.YesNo) == MessageBoxResult.No;
        }

        public bool Cancel { get; private set; }
    }
}
